<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <meta name="geometry" content="interval">
  <link rel="stylesheet" href="./assets/common.css">
  <title>Histogram Binning</title>
</head>

<body>
  <div id="canvas"></div>
  <script src="./assets/jquery-3.2.1.min.js"></script>
  <script src="./assets/data-set.min.js"></script>
  <script src="../build/g2.js"></script>
  <script>
    $.getJSON('./data/diamond.json', data => {
      const ds = new DataSet();
      const dv = ds.createView('diamond').source(data);
      dv.transform({
        type: 'bin.histogram',
        field: 'depth',
        as: [ 'depth', 'count' ]
      });
      const chart = new G2.Chart({
        container: 'canvas',
        forceFit: true,
        height: window.innerHeight
      });
      chart.source(dv);
      chart.tooltip({
        crosshairs: false,
        showTitle: false
      });
      chart.interval().position('depth*count');
      chart.render();
    });
  </script>
</body>

</html>
